﻿package
{
import com.urbansquall.chaos.PseudoRandom;
import com.urbansquall.chaos.RandomizedCombo;
import com.urbansquall.chaos.WeightedRandom;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.Dictionary;
import flash.utils.getTimer;

public class Main extends Sprite
{
	
	public function Main():void
	{
		if (stage) init();
		else addEventListener(Event.ADDED_TO_STAGE, init);
	}
	
	private function init(e:Event = null):void
	{
		removeEventListener(Event.ADDED_TO_STAGE, init);
		// entry point
		
		testChangeWeight();
		return;
		
		var random : PseudoRandom = new PseudoRandom( 1 );
		
		var combo : RandomizedCombo = new RandomizedCombo( random );
		
		combo.createCategory( "entre", [ "big mac" ] );
		combo.createCategory( "side", [ "fries", "salad" ] );
		combo.createCategory( "drink", [ "coke" ] );
		
		traceDictionary( combo.generateCombo() );
		traceDictionary( combo.generateCombo() );
		traceDictionary( combo.generateCombo() );
		traceDictionary( combo.generateCombo() );
	}
	
	private function testChangeWeight() : void
	{
		var weightedOption : WeightedRandom = new WeightedRandom();
		
		var opt1 : Object = new Object();
		opt1[ name ] = "opt1";
		
		var opt2 : Object = new Object();
		opt2[ name ] = "opt2";
		
		weightedOption.registerOption( opt1, 1.0 );
		weightedOption.registerOption( opt2, 1.0 );
		
		weightedOption.changeWeight( opt2, 0.5 );
		
		trace( weightedOption.toString() );
	}
	
	private function traceDictionary( a_dictionary : Dictionary ) : void
	{
		trace( "" );
		for( var key : String in a_dictionary )
		{
			trace( key + ": " + a_dictionary[ key ] );
		}
	}
	
}
}